#!/bin/sh
filepath=$(cd "$(dirname "$0")"; pwd)
. rt.comm
rt_init
config_cont=`rtinfo`
if [ "$config_cont" == "" ]; then 
    rt_noconf
    exit 0  
fi
dst_ip=`echo "$config_cont"|awk  -F= '{if($1~/dst_ip/)print $2}'`
dst_port=`echo "$config_cont"|awk  -F= '{if($1~/dst_port/)print $2}'`
dst_dir=`echo "$config_cont"|awk  -F= '{if($1~/dst_dir/)print $2}'`
dst_user=`echo "$config_cont"|awk  -F= '{if($1~/dst_user/)print $2}'`
dst_pwd=`echo "$config_cont"|awk  -F= '{if($1~/dst_pwd/)print $2}'`
jump_ip=`echo "$config_cont"|awk  -F= '{if($1~/jump_ip/)print $2}'`
jump_port=`echo "$config_cont"|awk  -F= '{if($1~/jump_port/)print $2}'`
jump_tmpdir=`echo "$config_cont"|awk  -F= '{if($1~/jump_tmpdir/)print $2}'`
jump_user=`echo "$config_cont"|awk  -F= '{if($1~/jump_user/)print $2}'`
jump_pwd=`echo "$config_cont"|awk  -F= '{if($1~/jump_pwd/)print $2}'`


echo "expect $filepath/rtssh.expect \"$jump_ip\" \"$jump_port\" \"$jump_user\" \"$dst_ip\" \"$dst_port\" \"$dst_dir\" \"$dst_user\"  \"$*\""
#expect $filepath/rtssh.expect "$jump_ip" "$jump_port" "$jump_user" "$jump_pwd" "$dst_ip" "$dst_port" "$dst_dir" "$dst_user" "$dst_pwd" "$*" | grep -v  "cd $dst_dir"|grep -v rtssh.expect|grep -A5000  $dst_user.*$dst_dir
#expect $filepath/rtssh.expect "$jump_ip" "$jump_port" "$jump_user" "$jump_pwd" "$dst_ip" "$dst_port" "$dst_dir" "$dst_user" "$dst_pwd" "$*" | grep -v  "$dst_user.*cd $dst_dir"| awk "/$dst_user.*`basename $dst_dir`/,/$dst_user.*`basename $dst_dir`.*exit/"
expect $filepath/rtssh.expect "$jump_ip" "$jump_port" "$jump_user" "$jump_pwd" "$dst_ip" "$dst_port" "$dst_dir" "$dst_user" "$dst_pwd" "$*" 
